package com.bwie.init;

import com.bwie.common.pojo.dto.HouseDto;
import com.bwie.common.pojo.po.HousePo;
import com.bwie.es.mapper.HouseEsMapper;
import com.bwie.pojo.HousePoEs;
import com.bwie.service.HouseService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@Component
public class HouseInitSynchronousEs{
    @Autowired
    private HouseService houseService;
    @Autowired
    private HouseEsMapper houseEsMapper;
    @PostConstruct
    public void initSynchronousEs(){
        HouseDto houseDto = new HouseDto();
        houseDto.setPageNum(1);
        houseDto.setPageSize(1000);
        //查询数据
        List<HousePo> houseList = houseService.getHouseListSynchronousEs(houseDto);
        ArrayList<HousePoEs> list = new ArrayList<>();
        //同步数据
        for (HousePo housePo : houseList) {
            HousePoEs housePoEs = new HousePoEs();
            BeanUtils.copyProperties(housePo,housePoEs);
            list.add(housePoEs);
        }
//        houseEsMapper.insertBatch(list);
    }

}
